//
//  BuyRecordCell2.m
//  YunGou
//
//  Created by macbook on 16/5/20.
//  Copyright © 2016年 macbook. All rights reserved.
//

#import "BuyRecordCell2.h"
#import <UIImageView+WebCache.h>
#import "NSString+DateTransform.h"

@interface BuyRecordCell2 ()
@property (weak, nonatomic) IBOutlet UIImageView *thumbImg;
@property (weak, nonatomic) IBOutlet UILabel *goodsName;
@property (weak, nonatomic) IBOutlet UILabel *qihao;
@property (weak, nonatomic) IBOutlet UILabel *partNum;
@property (weak, nonatomic) IBOutlet UILabel *winner;
@property (weak, nonatomic) IBOutlet UILabel *announceTime;
@property (weak, nonatomic) IBOutlet UILabel *totalNeed;

@end

@implementation BuyRecordCell2

- (void)awakeFromNib {
    // Initialization code
}

- (void)setModel:(ProductModel *)model{
    [_thumbImg sd_setImageWithURL:[NSURL URLWithString:[ImageUrl stringByAppendingString:model.thumb]]];
    [_thumbImg setAccessoryObject:model];
    _thumbImg.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
    [_thumbImg addGestureRecognizer:tap];
    _goodsName.text = model.title;
    _qihao.text = [NSString stringWithFormat:@"参与期号：%@",model.qishu];
    _partNum.text = model.gonumber;
    _winner.text = model.username;
    _announceTime.text = [NSString timeTransformWithString:[NSString stringWithFormat:@"%lf",model.q_end_time] andFormatter:@"yyyy-MM-dd HH:mm:ss"];
    _totalNeed.text = [NSString stringWithFormat:@"总需：%ld",model.zongrenshu];
}

- (void)handleTap:(UITapGestureRecognizer *)tap{
    ProductModel *model = [tap.view getAccessoryObject];
    if(self.imageClickBlock){
        self.imageClickBlock(model);
    }
}


- (IBAction)lookDetailClicked:(id)sender {
    if (self.buyRecordBlock) {
        self.buyRecordBlock();
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
